home *** CD-ROM | disk | FTP | other *** search
/ Dark Sector - Press Kit (USA) / Dark Sector - Press Kit (USA).iso / mac / expressinstall.as < prev    next >
Text File  |  2006-05-19  |  4KB  |  98 lines

  1. /**
  2.  * expressinstall.as v1.0 - http://blog.deconcept.com/swfobject/
  3.  * 
  4.  * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
  5.  * http://www.opensource.org/licenses/mit-license.php
  6.  *
  7.  *  Updated: 12-20-2005
  8.  *
  9.  * Use this file to invoke the Macromedia Flash Player Express Install functionality
  10.  * This file is intended for use with the SWFObject embed script. You can download SWFObject 
  11.  * and this file at the following URL: http://blog.deconcept.com/swfobject/
  12.  *
  13.  * * SWFObject is the embed script formerly known as FlashObject. The name changed
  14.  *    due to legal reasons.
  15.  *
  16.  * Usage: 
  17.  *          var ExpressInstall = new ExpressInstall();
  18.  *          
  19.  *          // test to see if install is needed:
  20.  *          if (ExpressInstall.needsUpdate) { // returns true if update is needed
  21.  *              ExpressInstall.init(); // starts the update
  22.  *          }
  23.  *          // these actions can be placed on a button for extra 
  24.  *          // functionality (see fo_tester.fla), or can be invoked at the start of the movie
  25.  *
  26.  *    NOTE: Your Flash movie must be at least 214px by 137px in order to use ExpressInstall.
  27.  *        Please see http://blog.deconcept.com/swfobject/ for other notes.
  28.  *
  29.  */
  30.  
  31. var ExpressInstall = function():Void {
  32.     // does the user need to update?
  33.     this.needsUpdate = (_root.MMplayerType == undefined) ? false : true;
  34. }
  35.  
  36. ExpressInstall.prototype = {
  37.     init: function():Boolean {
  38.         if (this.needsUpdate) {
  39.             this.loadUpdater();
  40.             return true;
  41.         } else {
  42.             return false;
  43.         }
  44.     },
  45.  
  46.     loadUpdater: function():Void {
  47.         System.security.allowDomain("fpdownload.macromedia.com");
  48.  
  49.         // hope that nothing is at a depth of 10000000, you can change this depth if needed, but you want
  50.         // it to be on top of your content if you have any stuff on the first frame
  51.         this.updater = _root.createEmptyMovieClip("expressInstallHolder", 10000000);
  52.         
  53.         // register the callback so we know if they cancel or there is an error
  54.         var _self = this;
  55.         this.updater.installStatus = _self.onInstallStatus;
  56.         this.hold = this.updater.createEmptyMovieClip("hold", 1);
  57.  
  58.         // can't use movieClipLoader because it has to work in 6.0.65
  59.         this.updater.onEnterFrame = function():Void {
  60.         if (typeof this.hold.startUpdate == 'function') {
  61.                 _self.initUpdater();
  62.                 this.onEnterFrame = null;
  63.             }
  64.         }
  65.  
  66.         var cacheBuster:Number = Math.random();
  67.         this.hold.loadMovie("http://fpdownload.macromedia.com/pub/flashplayer/update/current/swf/autoUpdater.swf?"+ cacheBuster);
  68.     },
  69.  
  70.     initUpdater: function():Void {
  71.         this.hold.redirectURL = _root.MMredirectURL;
  72.         this.hold.MMplayerType = _root.MMplayerType;
  73.         this.hold.MMdoctitle = _root.MMdoctitle;
  74.         this.hold.startUpdate();
  75.     },
  76.  
  77.     onInstallStatus: function(msg):Void {
  78.         if (msg == "Download.Complete") {
  79.             // Installation is complete. In most cases the browser window that this SWF 
  80.             // is hosted in will be closed by the installer or manually by the end user
  81.         } else if (msg == "Download.Cancelled") {
  82.             // The end user chose "NO" when prompted to install the new player
  83.             // by default no User Interface is presented in this case. It is left up to 
  84.             // the developer to provide an alternate experience in this case
  85.  
  86.             // feel free to change this to whatever you want, js errors are sufficient for this example
  87.             getURL("javascript:alert('This content requires a more recent version of the Macromedia Flash Player.')");
  88.         } else if (msg == "Download.Failed") {
  89.             // The end user failed to download the installer due to a network failure
  90.             // by default no User Interface is presented in this case. It is left up to 
  91.             // the developer to provide an alternate experience in this case
  92.  
  93.             // feel free to change this to whatever you want, js errors are sufficient for this example
  94.             getURL("javascript:alert('There was an error downloading the Flash Player update. Please try again later, or visit macromedia.com to download the latest version of the Flash plugin.')");
  95.         }
  96.     }
  97. }
  98.